// import request from './request'
import axios from "axios"
axios.defaults.adapter = function(config) {
    return new Promise((resolve, reject) => {
           var settle = require('axios/lib/core/settle');
           var buildURL = require('axios/lib/helpers/buildURL');
           var buildFullPath = require('axios/lib/core/buildFullPath');
           let fullurl = buildFullPath(config.baseURL,config.url)
           uni.request({
               method: config.method.toUpperCase(),
               url: buildURL(fullurl, config.params, config.paramsSerializer),
               header: config.headers,
               data: config.data,
               dataType: config.dataType,
               responseType: config.responseType,
               sslVerify: config.sslVerify,
               complete:function complete(response){
                   response = {
                     data: response.data,
                     status: response.statusCode,
                     errMsg: response.errMsg,
                     header: response.header,
                     config: config
                   };
                   
               settle(resolve, reject, response);
               }
           })
       })
}
// let baseUrl = 'http://172.17.145.161:3000'
let baseUrl = 'http://1.15.189.19:3000'

// 查询医院
export const queryHospital = (data)=>{
    return axios({url:baseUrl+'/hospital/selectHospital', method:'POST', data})
}

// 获取核酸地区的城市列表
export const queryCityMenu = ()=>{
    return axios({url:baseUrl + '/getCity/menu', method:"get"})
}

// 查询该地区的核酸位置
export const queryNucleicAcidByCity = (city)=>{
    return axios({url:baseUrl + `/query/hesuang?city=${city}`, method:'get'})
}

// 获取疫情数据
export const queryEpidemicSituationCount = ()=>{
    return axios({url:'https://c.m.163.com/ug/api/wuhan/app/data/list-total', method:'get'})
}

// 获取相应部位的菜单
export const getDataByPart=(partName)=>{
    return axios({url:baseUrl+ `/getDataByPart?part=${partName}`, method:'get'})
}

// 获取相应部位的菜单
export const getDataBySymptomName=(partName)=>{
    return axios({url:baseUrl+ `/getDataBySymptomName?name=${partName}`, method:'get'})
}

// 根据医院id查详情
export const selectHospitalById = (id)=>{
    return axios({url:baseUrl + `/hospital/selectHospitalById?id=${id}`, method:"get"})
}

// 根据科室医生和医院id查询医生列表
export const queryDoctorByDepartment = (hospitalId,department)=>{
    return axios({url:baseUrl + '/department/doctor' ,method:'post', data:{hospitalId, department}})
}

// 推荐的疫苗
export const queryRecommendVaccine = ()=>{
    return axios({url:baseUrl + '/vaccine/recommend', method:"post"})
}

// 按关键词搜索疫苗
export const queryVaccineByCatalogue = (age)=>{
    return axios({url:baseUrl + '/vaccine/byAge', method:'post', data:{age}})
}

// 根据id查疫苗详情
export const queryVaccineDetailById = (id)=>{
    return axios({url:baseUrl + '/vaccine/selectById', method:'post', data:{id}})
}

// 儿童疫苗接种页面数据
export const queryVaccineChildren = ()=>{
    return axios({url:baseUrl + '/vaccine/chird', method:"post"})
}

// 疫苗搜索
export const searchVaccine = (keyword)=>{
    return axios({url:baseUrl + '/vaccine/allSelect', method:'post', data:{name:keyword}})
}

// 病友圈列表
export const queryCircleList = ()=>{
    return axios({url:'http://172.17.145.161:3000/sickfriend/species', method:'post'})
}

// 根据id查询话题
export const queryCircleDetail = (id)=>{
    return axios({url:'http://172.17.145.161:3000/sickfriend/species/selectById', method:'post', data:{id}})
}

// 根据id查询帖子详情
export const queryPostingByCircleId = (id)=>{
    return axios({url:'http://172.17.145.161:3000/sickfriend/posting/bySpeciesId', method:'post', data:{id}})
}


// 测试接口
// async function test(){
//     let result = await getDataBySymptomName("口")
//     console.log(result)
// }
// test()
